home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / c_toolbx.arc / GENDATA2.C < prev    next >
Encoding:
C/C++ Source or Header  |  1988-03-30  |  766 b   |  36 lines

  1. /* gendata2.c - generate test data for VIEW program */
  2. #include "stdio.h"
  3. #include "cminor.h"
  4.  
  5. FILE *gfopen()    ;
  6.  
  7. main(argc,argv)
  8.   int    argc  ;
  9.   char    *argv[]  ;
  10.   {
  11.      long  nc , i , nl    ;
  12.      char  s[100]  ;
  13.      FILE  *fp    ;
  14.  
  15.      if( argc < 2 ) exit(1)  ;
  16.      fp = gfopen(argv[1],"w",BIN_MODE)  ;
  17.      if( fp == NULL ) exit(2)  ;
  18.  
  19.      printf("number of characters / line :")  ;
  20.      scanf("%1d",&nl) ;
  21.      nl = nl - 8  ;        /* allow for line no. and CR/LF  */
  22.      for(i=0 ; i < nl ; i= i+1) /* set up string for line    */
  23.     {  s[i] = ' ' + i ;  }
  24.      s[i] = '\0'  ;
  25.  
  26.      printf("number of lines:")  ;
  27.      scanf("%1d",&nc)  ;
  28.  
  29.      for(i=0 ; i < nc ; i= i+1 )
  30.     { fprintf(fp,"%51d %s\r\n",i,s)  ;  }
  31.      fclose(fp)  ;
  32.   }
  33.  
  34.  
  35.  
  36.